﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Lab2
{
    
    public class PhanSo
    {
        
        public int Tu { get; set; }
        private int mau;

        public int Mau
        {
            get
            {
                if (mau != 0)
                    return mau;
                else
                    return int.MaxValue;
            }
            set { mau = value; }
        }

        public enum Operator
        {
            Addition,
            Subtraction,
            Multiplication,
            Division 
        }
        //
        public PhanSo() { }
        public PhanSo(int tu, int mau) {
            this.Tu = tu;
            this.Mau = mau;
        }
        public PhanSo Operation(PhanSo a, PhanSo b, Operator o)
        {
            int t = 0, m = 0;
            if (o == Operator.Addition)
            {
                t = a.Tu * b.Mau + a.Mau * b.Tu;
                m = a.Mau * b.Mau;
            }
            else if (o == Operator.Subtraction)
            {
                t = a.Tu * b.Mau - a.Mau * b.Tu;
                m = a.Mau * b.Mau;
            }
            else if (o == Operator.Multiplication)
            {
                t = a.Tu * b.Tu;
                m = a.Mau * b.Mau;
            }
            else
            {
                t = a.Tu * b.Mau;
                m = a.Mau * b.Tu;
            }

            return new PhanSo(t, m);
        }

        public List<PhanSo> CreateList(int n)
        {
            List<PhanSo> l = new List<PhanSo>();
            for (int i = 1; i <= n; i++)
            {
                PhanSo p = new PhanSo(1, i);
                l.Add(p);
            }
            return l;
        }
        
    }
}